#ifndef MPLAYER_H
#define MPLAYER_H

#include <QObject>
#include <QtDebug>
#include <QMessageBox>
#include <QApplication>
#include <QFile>
#include <QSettings>
#include <QProcess>

#ifndef __cplusplus
extern "C"
{
#endif

//c程序的接口来自linux，所以，该qt程序只能在linux下进行编译
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <limits.h>
#include <errno.h>

#ifndef __cplusplus
}
#endif

class MPlayer: public QObject
{
    Q_OBJECT
public:
    MPlayer();
    ~MPlayer();
    int cmdWrite(QString cmdString);
    void setWidthHeight(int width, int height);
    void start();
    void pause();
    void go_on();
    bool isPlay();

private:
    bool playFlag;
    int width, height;
    int mplayer_fifo;
    QString fifo_file_path;
    QSettings *settings;
    QString mplayerPath;
    QString playUrl;
    QProcess *process;
    void finished();
    int init_mplayer_fifo();

};

#endif // MPLAYER_H
